#include <fcntl.h>
#include <stdio.h>
#include <string.h>

int main()
{
/*
	int fd = open("dup.dat",O_CREAT | O_RDWR | O_APPEND,0666);
	int fd2 = fcntl(fd , F_DUPFD , 5);
	printf("%d\n",fd2);  
	int flag = fcntl(fd , F_GETFL );
	printf("flag = %d\n",flag);	
	if(flag & O_APPEND) printf("append\n");
	if((flag & 3) ==  O_RDWR) printf("read && write\n");
	if((flag & 3) ==  O_WRONLY) printf("writeonly\n");
	if((flag & 3) ==  O_RDONLY) printf("readonly\n");
	//can't get
	if((flag & 3) ==  O_CREAT) printf("create\n");
	fcntl(fd , F_SETFL , O_CREAT | O_TRUNC );
	printf("change...\n");
   	int flag2 = fcntl(fd , F_GETFL);
	if(flag2 & O_APPEND) printf("append\n");
	if((flag2 & 3) ==  O_RDWR) printf("read && write\n");
	if((flag2 & 3) ==  O_WRONLY) printf("writeonly\n");
	if((flag2 & 3) ==  O_RDONLY) printf("readonly\n");
*/

	int fd = open("fcntl.txt", O_RDWR);
	if(fd == -1) perror("open") , exit(-1);
	
	struct flock lock ;
}
